package org.example.myleet.p1736;

public class Solution {
    public String maximumTime(String time) {
        StringBuilder sb = new StringBuilder();
        char c0 = time.charAt(0);
        char c1 = time.charAt(1);
        if (c0 == '?') {
            if (c1 == '?') {
                sb.append(2);
            } else if (c1 > '3') {
                sb.append(1);
            } else {
                sb.append(2);
            }
        } else {
            sb.append(c0);
        }
        if (c1 == '?') {
            if (c0 == '?') {
                sb.append(3);
            } else if (c0 < '2') {
                sb.append(9);
            } else {
                sb.append(3);
            }
        } else {
            sb.append(c1);
        }
        sb.append(':');
        char c3 = time.charAt(3);
        if (c3 == '?') {
            sb.append(5);
        } else {
            sb.append(c3);
        }
        char c4 = time.charAt(4);
        if (c4 == '?') {
            sb.append(9);
        } else {
            sb.append(c4);
        }
        return sb.toString();
    }
}
